export const beginTimeOfDay = (date: number):number => {
  const curDate = new Date(date)
  curDate.setHours(0,0,0,0)
  return curDate.getTime()
}

export const formatDate = (num: number): string => {
  let date = new Date(num)
  let year = date.getFullYear()
  let month = date.getMonth()+1
  let day = date.getDate()
  let m = month < 10 ? '0' + month : month
  let d = day < 10 ? '0' + day : day
  return `${year}/${m}/${d}`
}

export const beginTimeOfDay2 = (date: Date) => {
  let d = new Date(date.getFullYear(), date.getMonth(), date.getDate())
  return d.getTime()
}